export namespace subgame002.tools {


    //牌序- 2, A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3
    //红桃- 51,50,49,48,47,46,45,44,43,42,41,40,39
    //方片- 38,37,36,35,34,33,32,31,30,29,28,27,26
    //梅花- 25,24,23,22,21,20,19,18,17,16,15,14,13
    //黑桃- 12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0

    let suitsStr = ['黑桃', '梅花', '方片', '红心'];
    let ranksStr = ['3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', '2'];

    let suitsSign = ['♠', '♣', '♦', '♥'];

    export function cardIdToTexName(cardId: number) {
        if (cardId == null || cardId < 0) return null;
        let suit = Math.floor(cardId / 13);
        let rank = cardId % 13;
        return `${suitsStr[suit]}${ranksStr[rank]}`;
    }

    export function TexNameToCardId(texName: string) {
        if (texName == null || texName.length < 2) return null;
        let suit = suitsStr.indexOf(texName[0]);
        let rank = ranksStr.indexOf(texName[1]);
        return suit * 13 + rank;
    }

    export function cardIdToSymbol(cardId: number) {
        if (cardId == null || cardId < 0) return null;
        let suit = Math.floor(cardId / 13);
        let rank = cardId % 13;
        return `${suitsSign[suit]}${ranksStr[rank]}`;
    }

    export function SymbolToCardId(symbol: string) {
        if (symbol == null || symbol.length < 2) return null;
        let suit = suitsSign.indexOf(symbol[0]);
        let rank = ranksStr.indexOf(symbol[1]);
        return suit * 13 + rank;
    }

}
